package realQuestion.jingwei;

public class Main2 {

    public double calSqrt (double number) {
        if ( number<0){
            return  -1;
        }
        double left=0;
        double right=number;
        double ans=0;

        while (left<=right){
            double mid=(left+right)/2;
            double square=mid*mid;
            if (Math.abs(square-number)<1e-6){
                ans=mid;
                break;
            }else  if (square>number){
                right=mid-1e-6;
            }else if (square<number){
                left=mid+1e-6;
            }
        }
        return  ans;


    }

}
